export const flat =  function (array) {
    let result = []
    array.forEach(item => {
        result.push(Array.isArray(item) ? flat(item) : item)
    })
    return result
}

export const reduceFlat = function (array, depth) {
    return depth > 0 ? array.reduce((pre, cur) => {
        return pre.concat(Array.isArray(cur) ? reduceFlat(cur, depth - 1) : cur)
    }, []) : array.slice()
}